<template>
  <j-modal
    :title="title"
    :width="width"
    :visible="visible"
    :confirmLoading="confirmLoading"
    switchFullscreen
    @ok="handleOk"
    @cancel="handleCancel"
    cancelText="关闭">
    <a-spin :spinning="confirmLoading">
      <a-form :form="form">

        <a-form-item label="当前结算" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <!-- <a-textarea v-decorator="['isMonth']" :rows="2" placeholder="选择结算方式"></a-textarea> -->
             <a-select  v-decorator="['isMonth']" style="width: 120px" loading >
                <a-select-option value="0">
                   普通用户
                </a-select-option>
              <a-select-option value="1">
                 月结
                  </a-select-option>
              </a-select>
        </a-form-item>
    
 
         <a-form-item label="设计月结额度" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['monthLines']"  placeholder="填写月结额度" type="number" ></a-input>
        </a-form-item>

        

      </a-form>
    </a-spin>
  </j-modal>
</template>

<script>

import { deleteAction, getAction, putAction, postAction, downFile, getFileAccessHttpUrl } from '@/api/manage'
import pick from 'lodash.pick'
import { validateDuplicateValue } from '@/utils/util'
import JDate from '@/components/jeecg/JDate'
import JUpload from '@/components/jeecg/JUpload'

export default {
    name: 'LgyxTrainDataModalZ',
    components: {
        JDate,
        JUpload
    },
    data () {
        return {
            userId:'',
            form: this.$form.createForm(this),
            title: '操作',
            width: 800,
            visible: false,
            model: {},
            labelCol: {
                xs: { span: 24 },
                sm: { span: 5 }
            },
            wrapperCol: {
                xs: { span: 24 },
                sm: { span: 16 }
            },
            confirmLoading: false,
            validatorRules: {
            },
            url: {
                add: '/BackCust/setUserMouth',
                edit: '/BackCust/setUserMouth'
            }
        }
    },
    created () {
       
    },
    methods: {
        add () {
            this.edit({})
        },
        edit (record) {
            this.userId=record;
            console.log("输出看一看吧"+this.userId);
            this.form.resetFields()
            this.model = Object.assign({}, record)
            console.log(2222)
            console.log(this.model)
            this.visible = true
            this.$nextTick(() => {
                this.form.setFieldsValue(pick(this.model, 'id', 'jujuyuanyin2'))
            })
        },
        close () {
            this.$emit('close')
            this.visible = false
        },
        handleOk () {
            
            
            const that = this
            // 触发表单验证
            this.form.validateFields((err, values) => {
                if (!err) {
                    that.confirmLoading = true
                    let httpurl = ''
                    let method = ''
                    if (!this.model.id) {
                        httpurl += this.url.add
                        method = 'post'
                    } else {
                        httpurl += this.url.edit
                        method = 'get'
                    }
                    let formData = Object.assign(this.model, values)
			        formData['userId']=this.userId;
                    getAction(httpurl, formData).then((res) => {
				
					  console.log(method)
                        if (res.success) {
                            that.$message.success(res.message)
                            that.$emit('aaa')
                        } else {
                            that.$message.warning(res.message)
                        }
                    }).finally(() => {
                        that.confirmLoading = false
                        that.close()
                    })
                }
            })
        },
        handleCancel () {
            this.close()
        },
        popupCallback (row) {
            this.form.setFieldsValue(pick(row, 'id', 'jujueyuanyin'))
        }

    }
}
</script>
